<template>
  <div class="app-container">
     <!-- 表格 -->
    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="tableList"
      height="280"
      border
      fit
      highlight-current-row
      style="width: 100%;"
      @sort-change="sortChange"
    >
      <el-table-column prop="id" label="ID" align="center" width="80">
        <template slot-scope="{row}">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="username" label="建筑名称" width="200">
        <template slot-scope="{row}">
          <span>{{ row.username }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="userType" label="建筑属性" width="100">
        <template slot-scope="{row}">
          <span>{{ row.userType }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="totalArea" label="总面积(㎡)">
        <template slot-scope="{row}">
          <span>{{ row.totalArea }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="supplyArea" label="供能面积(㎡)">
        <template slot-scope="{row}">
          <span>{{ row.supplyArea }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="supplyRate" label="供能比例">
        <template slot-scope="{row}">
          <span>{{ row.supplyRate }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="ecoRate" label="节能率">
        <template slot-scope="{row}">
          <span>{{ row.ecoRate }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="heatLoad" label="设计热负荷（KW）">
        <template slot-scope="{row}">
          <span>{{ row.heatLoad }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="coldLoad" label="设计冷负荷（KW）">
        <template slot-scope="{row}">
          <span>{{ row.coldLoad }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getList } from '@/api/loadAnalysis'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success', 
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getList().then(response => {
        this.tableList = response.data.items
        this.listLoading = false
      })
    }
  }
}
</script>
